/**
 * Title:       APScriptHandler.java
 * Copyright:   Copyright (c) 1996-2004 The Agent Factory Working Group. All rights reserved.
 * Licence:     This file is free software; you can redistribute it and/or modify
 *              it under the terms of the GNU Lesser General Public License as published by
 *              the Free Software Foundation; either version 2.1, or (at your option)
 *              any later version.
 *
 *              This file is distributed in the hope that it will be useful,
 *              but WITHOUT ANY WARRANTY; without even the implied warranty of
 *              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *              GNU Lesser General Public License for more details.
 *
 *              You should have received a copy of the GNU Lesser General Public License
 *              along with Agent Factory; see the file COPYING.  If not, write to
 *              the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *              Boston, MA 02111-1307, USA.
 */

package com.agentfactory.platform.util;

/**
 * Simple class of static method used for legging
 *
 * @author Robert Ross, Universitat Bremen
 */
public class Logger {
    public static final int LEVEL_NONE                          = 0;
    public static final int LEVEL_ERROR                         = 1;
    public static final int LEVEL_WARNING                       = 2;
    public static final int LEVEL_DETAIL                        = 3;

    public static final int MAIN                        =        6;
	
    public static final int DEFAULT_LEVEL                       = LEVEL_WARNING;
    
    private static int logLevel(int inClassLevel) {
		if (DEFAULT_LEVEL > inClassLevel) {
			return DEFAULT_LEVEL;
		} else {
			return inClassLevel;
		}
    }
    
    /**
	 * Log a warning message
	 */
    public static void warning(String inString, int inClassLevel) {
		if( (Logger.LEVEL_WARNING <= logLevel(inClassLevel)) ||
			   (Logger.MAIN < logLevel(inClassLevel))){
			System.out.println("WARNING: "+ inString);
		}
    }
    
    /*
	 * Log an error message
	 */
    public static void error(String inString, int inClassLevel) {
		if((Logger.LEVEL_ERROR <= logLevel(inClassLevel)) ||
			   (Logger.MAIN < logLevel(inClassLevel))){
			System.out.println("ERROR: "+ inString);
		}
    }
    
    /**
	 * Log a warning message
	 */
    public static void enter(String inString, int inClassLevel) {
		if((Logger.LEVEL_DETAIL <= logLevel(inClassLevel))
		||
			   (Logger.MAIN < logLevel(inClassLevel))){
			System.out.println("ENTER: "+ inString);
		}
    }
    
    /**
	 * Log a warning message
	 */
    public static void exit(String inString, int inClassLevel) {
		if((Logger.LEVEL_DETAIL <= logLevel(inClassLevel)||
			   (Logger.MAIN < logLevel(inClassLevel)))) {
			System.out.println("EXIT: "+ inString);
		}
    }
    
    /**
	 * Log a warning message
	 */
    public static void detail(String inString, int inClassLevel) {
		if((Logger.LEVEL_DETAIL <= logLevel(inClassLevel)) ||
			   (Logger.MAIN < logLevel(inClassLevel))){
			System.out.println("DETAIL: "+ inString);
		}
    }
    
}

